/*
 * @Author: ylq
 * @Date: 2022-04-15 09:40:23
 * @Desc: route
 * @Last Modified by: ylq
 * @Last Modified time: 2022-08-15 10:25:19
 */

import {
  Auth,
  BindFeishu,
  Home,
  Login,
  Cop,
  Sys,
  MainLayout,
  AddCop,
  CopDetail,
  CopDashboard,
  AddFinancing,
  CopFinancing,
  CapTableDetail,
  AddCapTable,
  EditCapTable,
  ProjectMeeting,
  TsMeeting,
  VotingMeeting,
  Implement,
  ImplementSpa,
  BridgeLoan,
  TestDoc,
  Vform,
  VImage,
  Admin,
  Config,
  Users,
} from '@/views/'

const Layout = (r) => require.ensure([], () => r(require('../layout/Layout')), 'layout')
const Error404 = (r) => require.ensure([], () => r(require('../layout/Error')), 'error')

const constantRouterMap = [
  {
    path: '/bind-feishu',
    component: BindFeishu,
    name: 'BindFeishu',
    meta: {
      pageTitle: '绑定飞书',
    },
  },

  {
    path: '/login',
    component: Login,
    name: 'Login',
    meta: {
      pageTitle: '登录',
    },
  },
  {
    path: '/auth',
    component: Auth,
    name: 'Auth',
    meta: {
      pageTitle: '海大授权',
    },
  },
  {
    path: '/vimage',
    name: 'VImage',
    component: VImage,
    meta: { pageTitle: '图片预览', noPermission: true },
  },
]
export default constantRouterMap

//动态路由
export const asyncRouterMap = () => {
  return [
    {
      path: '/',
      name: 'layout',
      component: Layout,
      redirect: { name: 'dashboard' },
      meta: { pageTitle: '首页' },
      children: [
        {
          path: '',
          component: MainLayout,
          name: 'MainLayout',
          redirect: { name: 'dashboard' },
          meta: { pageTitle: '首页' },
          children: [
            {
              path: '/cop',
              component: Cop,
              name: 'cop',
              meta: { pageTitle: '详情' },
            },
            {
              path: '/dashboard',
              component: Home,
              name: 'dashboard',
              meta: { pageTitle: '首页' },
            },
            {
              path: '/sys',
              component: Sys,
              name: 'sys',
              meta: { pageTitle: '系统管理' },
            },
          ],
        },
        // 新增公司 相关路由
        {
          path: '/add-cop',
          component: AddCop,
          name: 'add-cop',
          meta: { pageTitle: '添加公司' },
        },
        {
          path: '/cop-dashboard:cid',
          component: CopDashboard,
          name: 'cop-dashboard',
          meta: { pageTitle: '公司概览' },
        },
        {
          path: '/cop-detail:cid',
          component: CopDetail,
          name: 'cop-detail',
          meta: { pageTitle: '公司详情' },
        },
        // cid 为公司id，fid 为融资轮次id  ctid为CapTable的Id
        // 新增公司轮次 相关路由
        {
          path: '/add-financing:cid',
          component: AddFinancing,
          name: 'add-financing',
          meta: { pageTitle: '添加融资轮次' },
        },
        {
          path: '/cop-financing:cid-:fid',
          component: CopFinancing,
          name: 'cop-financing',
          meta: { pageTitle: '融资轮次详情' },
        },
        // cid 为公司id，fid 为融资轮次id  ctid为CapTable的Id
        // 新增公司轮次capTable 相关路由
        {
          path: '/cap-table-detail:cid-:fid',
          component: CapTableDetail,
          name: 'cap-table-detail',
          meta: { pageTitle: 'CapTable详情' },
        },
        {
          path: '/add-cap-table:cid-:fid',
          component: AddCapTable,
          name: 'add-cap-table',
          meta: { pageTitle: '添加CapTable' },
        },
        {
          path: '/edit-cap-table:cid-:fid-:ctid',
          component: EditCapTable,
          name: 'edit-cap-table',
          meta: { pageTitle: '编辑CapTable' },
        },

        // 上会流程 立项会  cid 为公司id，fid 为融资轮次id，pid为立项会编辑id
        {
          path: '/project-meeting:cid-:fid',
          component: ProjectMeeting,
          name: 'project-meeting',
          meta: { pageTitle: '立项会' },
        },
        {
          path: '/edit-project-meeting:cid-:fid-:pid',
          component: ProjectMeeting,
          name: 'edit-project-meeting',
          meta: { pageTitle: '编辑立项会' },
        },
        // 上会流程 TS会  cid 为公司id，fid 为融资轮次id，pid为TS会编辑id
        {
          path: '/ts-meeting:cid-:fid',
          component: TsMeeting,
          name: 'ts-meeting',
          meta: { pageTitle: 'TS会' },
        },
        {
          path: '/edit-ts-meeting:cid-:fid-:pid',
          component: TsMeeting,
          name: 'edit-ts-meeting',
          meta: { pageTitle: '编辑TS会' },
        },
        // 上会流程 投决会  cid 为公司id，fid 为融资轮次id，pid为投决会编辑id
        {
          path: '/voting-meeting:cid-:fid',
          component: VotingMeeting,
          name: 'voting-meeting',
          meta: { pageTitle: '投决会' },
        },
        {
          path: '/edit-voting-meeting:cid-:fid-:pid',
          component: VotingMeeting,
          name: 'edit-voting-meeting',
          meta: { pageTitle: '编辑投决会' },
        },

        // 执行流程  cid 为公司id，fid 为融资轮次id
        {
          path: '/implement:cid-:fid',
          component: Layout,
          name: 'implement',
          redirect: { name: 'implement-index' },
          meta: { pageTitle: '执行流程' },
          children: [
            {
              path: '',
              component: Implement,
              name: 'implement-index',
              meta: { pageTitle: '执行流程' },
            },
            {
              path: 'bridge-loan',
              component: BridgeLoan,
              name: 'bridge-loan',
              meta: { pageTitle: '过桥贷款' },
            },
            {
              path: 'implement-spa',
              component: ImplementSpa,
              name: 'implement-spa',
              meta: { pageTitle: '远景SPA' },
            },
          ],
        },
        {
          path: '/vform',
          component: Layout,
          name: 'vform',
          redirect: { name: 'vform-index' },
          meta: { pageTitle: '表单', noPermission: true },
          children: [
            {
              path: '',
              component: Vform,
              name: 'vform-index',
              meta: { pageTitle: '多维表单' },
            },
          ],
        },
        {
          path: '/admin',
          component: Admin,
          name: 'admin',
          redirect: { name: 'admin-config' },
          meta: { pageTitle: '后台管理', noPermission: true },
          children: [
            {
              path: 'config',
              component: Config,
              name: 'admin-config',
              meta: { pageTitle: '现场巡检' },
            },
            {
              path: 'users',
              component: Users,
              name: 'admin-users',
              meta: { pageTitle: '人员管理' },
            },
          ],
        },
        // xxxx

        // 这里是一个测试页面，其他路由，都写到上面
        {
          path: '/test-doc',
          component: TestDoc,
          name: 'test-doc',
          meta: { pageTitle: '组件测试页面' },
        },
      ],
    },
    {
      path: '*',
      component: Error404,
      name: 'error404',
      // redirect: {name: 'Dashboard'},
      meta: { pageTitle: '404' },
    },
  ]
}
